package com.penjin.android.activity.geren;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.penjin.android.R;
import com.penjin.android.domain.PenjinCompany;
import com.penjin.android.domain.PenjinStaff;
import com.penjin.android.domain.PenjinUser;
import com.penjin.android.service.UserService;
import com.penjin.android.utils.ToastHelper;
import com.penjin.android.view.TitleBarView;

/**
 * Created by maotiancai on 2015/12/19.
 */
public class GongsiInfoActivity extends Activity implements View.OnClickListener {

    private TextView gongsi;
    private TextView department;
    private TextView num;
    private TextView post;
    private TextView IDCard;
    private TextView telephone;
    private TextView email;
    private TextView position;
    private TextView born;
    private TextView marry;


    TitleBarView titleBarView;
    PenjinUser user;
    PenjinCompany company;
    PenjinStaff staff;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        setContentView(R.layout.layout_activity_gongsiinfo);
        init();

    }

    private void initData() {
        UserService userService = UserService.getInstance(getApplicationContext());
        user = userService.getCurrentUser();
        if (user == null) {
            ToastHelper.showNotLogin(getApplicationContext());
            finish();
        } else {
            if (user.isInCompany()) {
                company = userService.getCurrentCompany();
                staff = userService.getCurrentStaff();
            }
        }
    }

    private void init() {
        titleBarView = (TitleBarView) findViewById(R.id.titleBarView);
        titleBarView.setTitleBarListener(new TitleBarView.TitleBarListener() {
            @Override
            public void left(View view) {
                finish();
            }

            @Override
            public void center(View view) {

            }

            @Override
            public void right(View view) {

            }
        });
        gongsi = (TextView) findViewById(R.id.gongsiInfo_gongsi_edit);
        department = (TextView) findViewById(R.id.gongsiInfo_department_edit);
        num = (TextView) findViewById(R.id.gongsiInfo_num_edit);
        post = (TextView) findViewById(R.id.gongsiInfo_post_edit);
        IDCard = (TextView) findViewById(R.id.gongsiInfo_IdCard_edit);
        telephone = (TextView) findViewById(R.id.gongsiInfo_telephone_edit);
        email = (TextView) findViewById(R.id.gongsiInfo_email_edit);
        position = (TextView) findViewById(R.id.gongsiInfo_post_edit);
        born = (TextView) findViewById(R.id.gongsiInfo_born_edit);
        marry = (TextView) findViewById(R.id.gongsiInfo_marry_edit);

        gongsi.setOnClickListener(this);
        department.setOnClickListener(this);
        num.setOnClickListener(this);
        post.setOnClickListener(this);
        IDCard.setOnClickListener(this);
        telephone.setOnClickListener(this);
        email.setOnClickListener(this);
        position.setOnClickListener(this);
        born.setOnClickListener(this);
        marry.setOnClickListener(this);

        if (user.isInCompany()) {
            gongsi.setText(company.getCompanyName());
            department.setText(staff.getDepartment());
            num.setText(company.getCompanyPersonNumber());
            telephone.setText(company.getTelephone());
            email.setText(company.getEmail());
            position.setText(staff.getPosition());
        }else{
            ToastHelper.showNotBindCompany(getApplicationContext());
        }
    }


    @Override
    public void onClick(View v) {

    }
}
